<%@page contentType="text/html; charset=UTF-8" language="java"%>
<%@page import="com.travelsky.airchina.boarding.util.PageViewUtil"%>
<%@page import="com.travelsky.airchina.boarding.util.PageUtil"%>
<%@include file="/common/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>管理中心 - 品牌列表 </title>
	<meta name="robots" content="noindex, nofollow"/>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link href="${ctx}/css/system/general.css" rel="stylesheet" type="text/css" />
	<link href="${ctx}/css/system/main.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="${ctx}/js/checkFrameSet.js"></script>
	<script language="javascript" type="text/javascript" src="${ctx}/js/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript" src="${ctx}/js/jquery-1.4.min.js"></script>
	<script type="text/javascript" src="${ctx}/js/json.min.js"></script>
	<script type="text/javascript" src="${ctx}/js/operationTip.js"></script>
	<script type="text/javascript" src="${ctx}/js/jquery-select.js"></script>
	<script language="JavaScript">
	    function onchangeCategory(columnSelect){
	       var selectId = columnSelect.id;
	       var nextSelectId = parseInt(selectId.substring(10))+1;
	       if(columnSelect.value!=""){
		       $.getJSON("${ctx}/system/category/childcolumn",{pId:columnSelect.value},function(data){
		         if(data!=null && data.length>0){
		            $("#"+selectId).nextAll().remove();
		            $("#"+selectId).after("&nbsp;&nbsp;<select name='categoryId"+nextSelectId+"' id='categoryId"+nextSelectId+"' onchange='javascript:onchangeCategory(this);'></select>");
		            $("#categoryId"+nextSelectId).addOption("请选择","");
		            for(var i=0;i<data.length;i++){
		                $("#categoryId"+nextSelectId).addOption(data[i].name,data[i].id);
		            }
		         }else{
		            $("#"+selectId).nextAll().remove();
		         }
		       });
	       }else{
	           $("#"+selectId).nextAll().remove();
	       }
	    }
	</script>
</head>
<body>
<h1>
<c:if test="${USER_OPERATION_URIS_MAP['/system/brand']!=null}">
<span class="action-span"><a href="${ctx}/system/brand">新建品牌</a></span>
</c:if>
<span class="action-span1"><a href="#">管理中心</a>  - 品牌列表 </span>
<div style="clear:both"></div>
</h1>
<form method="post" action="${ctx}/system/brand/manage" id="listForm" name="listForm">
<table width="100%">
   <tr>
    <td width="15%">产品类目</td>
    <td colspan="3">
    <select id="categoryId0" name="categoryId0" onchange="javascript:onchangeCategory(this);">
       <option value="">请选择产品类目</option>
       <c:forEach items="${rootCategoryList}" var="varTemp">
         <c:choose>
           <c:when test="${cateIdMap[varTemp.id]!=null}">
       <option value="${varTemp.id}" selected="selected">${varTemp.name}</option>
           </c:when>
           <c:otherwise>
       <option value="${varTemp.id}">${varTemp.name}</option>
           </c:otherwise>
         </c:choose>
       </c:forEach>
    </select>
    <c:if test="${brandVO.categoryIds!=null}">
       <c:forEach items="${brandVO.categoryIds}" var="varTemp" varStatus="statusTemp">
          <c:if test="${map[varTemp]!=null}">
           &nbsp;&nbsp;<select id="categoryId${statusTemp.index+1}" name="categoryId${statusTemp.index+1}" onchange="javascript:onchangeCategory(this);">
            <option value="">请选择</option>
          <c:forEach items="${map[varTemp]}" var="mapValue">
            <c:choose>
              <c:when test="${cateIdMap[mapValue.id]!=null}">
            <option value="${mapValue.id}" selected="selected">${mapValue.name}</option>
              </c:when>
              <c:otherwise>
            <option value="${mapValue.id}">${mapValue.name}</option>
              </c:otherwise>
            </c:choose>
          </c:forEach>
          </select>
          </c:if>
       </c:forEach>
    </c:if>
    </td>
   </tr>
   <tr>
    <td width="15%">品牌名称</td>
    <td width="25%"><input type="text" id="brandName" name="brandName" value="${brandVO.name}"/></td>
    <td width="15%">类目名称</td>
    <td width="45%"><input type="text" id="categoryName" name="categoryName" value="${brandVO.categoryName}"/>&nbsp;&nbsp;<input type="submit" value="查询"/></td>
   </tr>
</table>
<div class="list-div" id="listDiv">
<table width="100%" cellpadding="3" cellspacing="1" id="listTable">
  <tr>
    <th>品牌名称</th>
    <th>类目名称</th>
    <th>状态</th>
    <th>操作</th>
  </tr>
  <c:forEach items="${list}" var="itemTemp" varStatus="statusTemp">
  <tr>
    <td class="first-cell">${itemTemp.name}
    </td>
    <td align="center">${itemTemp.categoryName}</td>
    <td align="center">
    <div class="statusDiv" id="statusDiv${itemTemp.id}">
	    <span id="status${itemTemp.id}">
	    <c:choose>
	      <c:when test="${itemTemp.status==1}">启用</c:when>
	      <c:when test="${itemTemp.status==0}">停用</c:when>
	      <c:otherwise>未知状态</c:otherwise>
	    </c:choose>
	    </span>
    </div>
    </td>
    <td align="center">
      <c:if test="${USER_OPERATION_URIS_MAP['/system/brand/update']!=null}"> <a href="${ctx}/system/brand/update/${itemTemp.id}" title="编辑">编辑</a></c:if>
    </td>
  </tr>
  </c:forEach>
  </table>
</div>
  <div class="page-navigation">
  <%
  PageUtil pageUtil = (PageUtil)request.getAttribute("pageUtil");
  PageViewUtil.printPage(out, pageUtil, "100%","listForm",request.getContextPath()+"/system/brand/manage","_self",false);
  %>
  </div>
</form>
</body>
</html>